<!DOCTYPE html>
<html lang="en" ng-app="xiao">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>测试ui-router</h2>
<div>
    <ul>
        <li><a ui-sref="user">用户</a></li>
        <li><a ui-sref="book">书籍</a></li>
        <li><a ui-sref="setting">设置</a></li>
    </ul>
</div>
<div ui-view></div>
</body>
</html>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script src="http://apps.bdimg.com/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
<script>

angular.module('xiao',['ui.router'])
    .controller('userInfoController',function($scope){
        $scope.name="xiaomeng"
    })
    .config(function($stateProvider,$urlRouterProvider){
        $urlRouterProvider.otherwise("/");
        $stateProvider
            .state('user',{
                url:"/user",
                templateUrl:"user/user.html"
            })
            .state('user.add',{
                url:"/add",
                templateUrl:"user/add.html"
            })
            .state('user.edit',{
                url:"/edit",
                templateUrl:"user/edit.html"
            })
            .state('user.del',{
                url:"/del",
                templateUrl:"user/del.html"
            })
            .state('book',{
                url:"/book",
                templateUrl:"book/book.html"
            })
            .state('book.add',{
                url:"/add",
                templateUrl:"book/add.html"
            })
            .state('book.edit',{
                url:"/edit",
                templateUrl:"book/edit.html"
            })
            .state('book.del',{
                url:"/del",
                templateUrl:"book/del.html"
            })
            .state('setting',{
                url:"/setting",
                views:{
                    '':{
                        templateUrl:"user/setting.html"
                    },
                    'info@setting':{
                        templateUrl:"user/info.html",
                        controller:"userInfoController"
                    },
                    'address@setting':{
                        templateUrl:"user/address.html"
                    }
                }
            })
    })
</script>